﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KCMS.BusinessLogic.Models;
using KCMS.BusinessLogic.Interfaces;
using StructureMap;

namespace KCMS.Areas.Admin.Controllers
{
    [Authorize]
    public class SizeController : Controller
    {
        private ISizeService sizeService = ObjectFactory.GetInstance<ISizeService>();
        public ActionResult Index()
        {
            var sizes = sizeService.getAll();
            return View(sizes);
        }
        [HttpGet]
        public ActionResult Create()
        {
            var size = new Size();
            return View(size);
        }
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Create(Size size)
        {
            sizeService.save(size);
            return RedirectToAction("Index");
        }
        [HttpGet]
        public ActionResult Edit(Guid id)
        {
            var model = sizeService.getById(id);
            return View(model);
        }
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Edit(Size size)
        {
            //Size old = productService.getById(size.Id);

            //UpdateModel<Size>(size);
            sizeService.update(size);
            return RedirectToAction("Index");
        }
        [HttpGet]
        public ActionResult Delete()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Delete(Guid id)
        {
            sizeService.delete(id);
            return RedirectToAction("Index");
        }

    }
}
